package com.love.travel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.love.common.log.annotation.Log;
import com.love.common.log.enums.BusinessType;
import com.love.common.security.annotation.RequiresPermissions;
import com.love.travel.domain.TravelProductItinerary;
import com.love.travel.service.ITravelProductItineraryService;
import com.love.common.core.web.controller.BaseController;
import com.love.common.core.web.domain.AjaxResult;
import com.love.common.core.utils.poi.ExcelUtil;
import com.love.common.core.web.page.TableDataInfo;

/**
 * 产品行程Controller
 * 
 * @author love
 * @date 2025-10-24
 */
@RestController
@RequestMapping("/itinerary")
public class TravelProductItineraryController extends BaseController
{
    @Autowired
    private ITravelProductItineraryService travelProductItineraryService;

    /**
     * 查询产品行程列表
     */
    @RequiresPermissions("travel:itinerary:list")
    @GetMapping("/list")
    public TableDataInfo list(TravelProductItinerary travelProductItinerary)
    {
        startPage();
        List<TravelProductItinerary> list = travelProductItineraryService.selectTravelProductItineraryList(travelProductItinerary);
        return getDataTable(list);
    }

    /**
     * 导出产品行程列表
     */
    @RequiresPermissions("travel:itinerary:export")
    @Log(title = "产品行程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TravelProductItinerary travelProductItinerary)
    {
        List<TravelProductItinerary> list = travelProductItineraryService.selectTravelProductItineraryList(travelProductItinerary);
        ExcelUtil<TravelProductItinerary> util = new ExcelUtil<TravelProductItinerary>(TravelProductItinerary.class);
        util.exportExcel(response, list, "产品行程数据");
    }

    /**
     * 获取产品行程详细信息
     */
    @RequiresPermissions("travel:itinerary:query")
    @GetMapping(value = "/{itineraryId}")
    public AjaxResult getInfo(@PathVariable("itineraryId") Long itineraryId)
    {
        return success(travelProductItineraryService.selectTravelProductItineraryByItineraryId(itineraryId));
    }

    /**
     * 新增产品行程
     */
    @RequiresPermissions("travel:itinerary:add")
    @Log(title = "产品行程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TravelProductItinerary travelProductItinerary)
    {
        return toAjax(travelProductItineraryService.insertTravelProductItinerary(travelProductItinerary));
    }

    /**
     * 修改产品行程
     */
    @RequiresPermissions("travel:itinerary:edit")
    @Log(title = "产品行程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TravelProductItinerary travelProductItinerary)
    {
        return toAjax(travelProductItineraryService.updateTravelProductItinerary(travelProductItinerary));
    }

    /**
     * 删除产品行程
     */
    @RequiresPermissions("travel:itinerary:remove")
    @Log(title = "产品行程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{itineraryIds}")
    public AjaxResult remove(@PathVariable Long[] itineraryIds)
    {
        return toAjax(travelProductItineraryService.deleteTravelProductItineraryByItineraryIds(itineraryIds));
    }
}
